﻿using System;
using System.Windows.Forms;

namespace ProjectEuler.UI
{
    public partial class ExceptionForm : Form
    {
        private Exception _exception;

        public static void ShowException(Exception ex)
        {
            using(var form = new ExceptionForm(ex))
            {
                form.ShowDialog();
            }
        }

        public ExceptionForm(Exception ex)
        {
            InitializeComponent();

            _exception = ex;
        }

        private void ExceptionForm_Load(object sender, EventArgs e)
        {
            this.Text = "Exception: " + _exception.GetType();
            this.errorMessageTextBox.Text = _exception.ToString();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
